function reverseList(self, head) {
  let cur = head
  let prev = null
  while (cur) {
    // ;[cur.next, prev, cur] = [prev, cur, cur.next]
    // or
    let nextTmp = cur.next
    cur.next = prev
    prev = cur
    cur = nextTmp
  }
  return prev
}

class List {
  constructor(data) {
    this.node = {
      value: data,
      next: null,
      prev: null,
    }
    this.list = [this.node]
  }
  put(data) {
    const node = {
      value: data,
      next: null,
      prev: this.list[this.list.length - 1],
    }
    this.list[this.list.length - 1].next = node
    this.list.push(node)
  }
  insert(value, index) {
    if (index > this.list.length) {
      return this.put(value)
    }
    const node = {
      value,
      next: this.list[index + 1],
      prev: this.list[index],
    }
    this.list[index].next = node
    this.list[index + 1].prev = node
    this.list.push(node)
  }
  take(node) {}
  get() {
    return this.list
  }
  del(node) {
    node.prev.next = node.next
    node.next.prev = node.prev
  }
}
const list = new List(1)
console.log(list)
